package com.cc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cc.mapper.GoodMapper;
import com.cc.service.GoodService;
import com.dy.cc.Good;
import com.dy.cc.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @author Lenovo
 * @description 针对表【goods】的数据库操作Service实现
 * @createDate 2024-11-20 10:07:40
 */
@Service
public class GoodServiceImpl extends ServiceImpl<GoodMapper, Good>
        implements GoodService {

    @Autowired
    private GoodMapper goodMapper;

    @Override
    public List<Good> findAll(Good good) {
        return goodMapper.findAll(good);
    }

    @Override
    public List<Good> xiao(Good good) {
        return goodMapper.xiao(good);
    }

    @Override
    public List<Good> shang(Good good) {
        return goodMapper.shang(good);
    }

    @Override
    public List<Good> price(Good good, Integer a) {
        LambdaQueryWrapper<Good> lam = new LambdaQueryWrapper<>();
        System.out.println("-----------------------------" + a);
        if (a == 1) {
            lam.orderByAsc(Good::getPrice);
        } else {
            lam.orderByDesc(Good::getPrice);
        }
        return baseMapper.selectList(lam);
    }

    @Override
    public List<Good> sousuo(Good good) {
        return goodMapper.sousuo(good);
    }
}
